import { request } from "@/utils"
import { message } from "antd"

export function getAlgor () {
  return request({
    url: '/get-algor',
    headers: {
      isLoading: false
    }
  }).catch(error => {
    // console.log(error.message)
    message.error('网络异常，请开启服务器')
  })
}

export function modifyAlgor (data) {
  return request({
    url: '/modify-algor',
    method: 'POST',
    data
  })
}


export function addAlgor (formData) {
  return request({
    url: '/upload',
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
    .then(() => {
      message.success('上传成功')
    }).catch(() => {
      message.error('上传失败')
    })
}

export function delAlgor (id) {
  return request({
    url: '/delete-algor',
    method: 'POST',
    data: {
      id
    }
  }).then(() => {
    message.success('删除成功')
  }).catch(() => {
    message.error('删除失败，有运行记录')
  })
}